#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, int> PII;

const int N = 2e5 + 10;

int a[N], b[N];
vector<PII> change;

int main()
{
	int T;
	cin >> T;
	while(T--)
	{
		int n; cin >> n;
		int cnt = 0;
		for(int i = 1; i <= n; i++) cin >> a[i];
		for(int i = 1; i <= n; i++)
		{
			cin >> b[i];
			if(b[i] == a[i]) cnt++;
		}
		if(n % 2 == 0 && cnt != 0) cout << "-1" << endl;
		else if(n % 2 != 0 && cnt > 1) cout << "-1" << endl;
		else
		{
			if(cnt == 0)
			{
				for(int i = 1; i <= n / 2; i++)
				{
					if(a[i] != b[n - i + 1])
				}
			}
			else
			{
				
			}
		}
 		
	}
	return 0;
}
